package cn.wen.yinxiu.product.controller;

import java.util.Arrays;
import java.util.Map;

import cn.wen.yinxiu.common.convention.result.Results;
import cn.wen.yinxiu.common.to.product.SkuLockTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import cn.wen.yinxiu.product.entity.StockSkuEntity;
import cn.wen.yinxiu.product.service.StockSkuService;
import cn.wen.yinxiu.common.toolkit.PageUtils;
import cn.wen.yinxiu.common.convention.result.ResultEntity;

/**
 *
 * @ClassName: StockSkuController
 * @Author 小飞
 * @Email coderwen22@163.com
 * @Date 2023-05-22 09:55:17
 * @Description: 商品库存的Controller层
 */
@RestController
@RequestMapping("/web")
public class StockSkuController {

    @Autowired
    private StockSkuService stockSkuService;

    /**
     * 通过用户ID获取用户的地址列表
     * @return
     */
    @GetMapping("/api/product/stock")
    ResultEntity<Boolean> getSkuHasStock(@RequestParam("skuId") Long skuId) {
        boolean res = stockSkuService.getSkuHasStock(skuId);
        return Results.success(res);
    }

    /**
     * 锁库存
     *
     * @return
     */
    @PostMapping("/web/api/product/lock/stock")
    ResultEntity<Boolean> orderLockStock(@RequestBody SkuLockTO lockTO) {
        boolean res = stockSkuService.orderLockStock(lockTO);
        return Results.success(res);
    }

}
